import java.sql.*;
public class myDb {
	static String url="jdbc:mysql://localhost:3308/priti";
	static String un="root"; 
	static String pw="snowpy";
	static Statement sm;
	static Connection con;


	public static  void  connection(){
		
		try{
		Class.forName("com.mysql.jdbc.Driver").newInstance();
		Connection con=DriverManager.getConnection(url,un,pw);
		}
		catch(Exception e)
		{
			System.out.println(e);
		}
		
}
	
public  ResultSet executeQuery(String q){
	
	ResultSet rs=null;
	
	try {
		sm = con.createStatement();
		 sm.executeQuery(q);

		 rs=sm.getResultSet();
		 
		sm.close();
		con.close();

		return rs;
	} 
	catch(Exception e) {
		System.out.println( e);
	}
return rs;
}

public  int update(String q)
		{
			
		int returnresult=0;
					
			try {
				sm = con.createStatement();
		   		returnresult = sm.executeUpdate(q);
		   		
		   	 sm.close();
		   	 con.close();
		   		return(returnresult);
			}
			 catch(Exception e) {
				System.out.println(e);
			}
			 return(returnresult);
			}
}     